import {useMemo} from 'react'
import {API} from '../api'
import {useAtomValue} from 'jotai'
import {JWTAtom} from './useLogin'
import {useNavigate} from 'react-router-dom';

export const useAPI = () => {
  const jwt = useAtomValue(JWTAtom)
  const navigate = useNavigate();
  return useMemo(() => {
    return new API(navigate,{ jwt: jwt ?? undefined })
  }, [jwt])
}
